﻿using System;
using System.Text;
using System.Xml;
using System.Xml.Serialization;

namespace DoodleLabyrinthLogic.Character
{
    public class Monster : BaseCharacter
    {
        public Monster(Guid id, string name, string description, int baseMeleeDefense, int baseMagicDefense, int baseAgility, int baseMeleeDamage, int baseMagicDamage, int baseHealth, int baseMmana, int level) : base(id, name, description, baseMeleeDefense, baseMagicDefense, baseAgility, baseMeleeDamage, baseMagicDamage, baseHealth, baseMmana, level)
        {
        }

        protected override void HandleCharacterDeath()
        {
            base.HandleCharacterDeath();

            Game.Instance.MainPlayer.AssignXP(this);
        }

        public virtual XmlDocument ToXML()
        {
            StringBuilder stringBuilder = new StringBuilder();
            XmlWriter xmlWriter = XmlWriter.Create(stringBuilder);
            XmlSerializer serializer = new XmlSerializer(typeof(Monster));
            serializer.Serialize(xmlWriter, this);

            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.LoadXml(stringBuilder.ToString());

            return xmlDocument;
        }
    }
}
